"""
@Author : 合肥一元数智教育科技有限公司
@Date :  2025/2/11 13:32
@Description :   python中的运算符

1.数学运算符
   +   -  *  /   %  //  **
2.逻辑运算
   and  or  not
3.比较运算
   ==  ！=  >  >=  <   <=
4.位运算
   &  |  ^
5.三目运算
   简写双分支结构
6.身份运算
    is   is not     id
7.赋值运算
   =  +=  -= *=  /=
8.成员运算
   in  not in

"""
num1 = 2
num2 = 3
print(f'{num1}+{num2} = {num1 + num2}')
print(f'{num1}-{num2} = {num1 - num2}')
print(f'{num1}*{num2} = {num1 * num2}')
print(f'{num1}/{num2} = {num1 / num2}')
print(f'{num1}//{num2} = {num1 // num2}')
print(f'{num1}**{num2} = {num1 ** num2}')
print(f'{num1}%{num2} = {num1 % num2}')

print("*" * 30)

bool_1 = False
bool_2 = False

# bool_1 = 0
# bool_2 = 2

'''
  and      变量  and  变量   -> True     只有两个变量全部为True 结果才为True
  or       变量  or  变量    -> False    只有两个变量全部为False 结果才为False
  not      取反    True  ->  False  -> True
'''
print(f'{bool_1} and {bool_2} = {bool_1 and bool_2}')
print(f'{bool_1} or {bool_2} = {bool_1 or bool_2}')
print(f'not {bool_2} = {not bool_2}')

print("*" * 30)

num1 = 2
num2 = 3
result = num1 == num2
print(f'{num1}=={num2} = {result}')
print(f'{num1}!={num2} = {num1 != num2}')
print(f'{num1}>{num2} = {num1 > num2}')
print(f'{num1}>={num2} = {num1 >= num2}')
print(f'{num1}<{num2} = {num1 < num2}')
print(f'{num1}<={num2} = {num1 <= num2}')

print("*" * 30)

'''
  位运算规则
  
  &    
      0100
      0101
      0100
  
  |
      0100
      0101
      0101
  
  ^    相同为零  不同为一
      0100
      0101
      0001
'''
num1 = 4  # 0100
num2 = 5  # 0101
print(f'{num1}&{num2} = {num1 & num2}')  # 4
print(f'{num1}|{num2} = {num1 | num2}')  # 5
print(f'{num1}^{num2} = {num1 ^ num2}')  # 1

print('*' * 30)

# 三目运算
age = 18
info = '成年' if age >= 18 else '未成年'
print(f'{age}岁是一个{info}人')

print('*' * 30)
str_info1 = 'hello'
str_info2 = 'hello'

# 判定两个字符串 是不是同一个数据
print(id(str_info1))
print(id(str_info2))
result = str_info1 is not str_info2
print(result)

print('*' * 30)

#  赋值运算符
num1 = 1
# num1 += 2  # num1 = num1 + 2
# num1 -= 2
# num1 *= 2
num1 /= 2
print(num1)

print('*' * 30)

str_info = 'hello'
str_sub = 'he'
#  判定 h 是不是包含在 hello
# result = str_sub in str_info
result = str_sub not in str_info
print(result)
